package timertast;

import java.util.Timer;
import java.util.TimerTask;


/*****
 * 使用TimerTask来实现定时
 */
public class TimerTaskTest {
	static long count = 0;
	
	public static void main(String[] args) {
		
		TimerTask task =new TimerTask() {
			@Override
			public void run() {
				count++;
				System.out.println(count);
			}
		};
		
		Timer timer = new Timer();
		// 天数
		long delay = 0;
		// 秒数
		long period = 1000;
		timer.scheduleAtFixedRate(task, delay, period);
		
	}
}
